package com.android.AndroidMusicSampler;

import android.R;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TableLayout;
import android.widget.TableRow;

public class MainActivity extends Activity implements View.OnClickListener {

    SoundManager mSoundManager = new SoundManager();
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        
        mSoundManager.initSounds(getBaseContext());
        mSoundManager.addSound(0, 1);

        TableLayout layout = new TableLayout(this);
        
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
        
        //layout.setLayoutParams(new TableLayout.LayoutParams(4, 5));
        layout.setLayoutParams(lp);
        layout.setStretchAllColumns(true);
        
        TableLayout.LayoutParams rowLp = new TableLayout.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT,
        1.0f);
        
        TableRow.LayoutParams cellLp = new TableRow.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT,
        1.0f);
        
        
        layout.setPadding(10, 10, 10, 10);

        for (int r = 0; r <= 3; r++) {
            TableRow tr = new TableRow(this);
            for (int c = 0; c <= 3; c++) {
                Button b = new Button(this);
                String bText = "";
                if (c == 0) bText += "B";
                if (c == 1) bText += "G";
                if (c == 2) bText += "F";
                if (c == 3) bText += "P";
                bText += "L";
                if (r == 0) bText += "O";
                if (r == 2) bText += "A";
                if (r == 1) bText += "E";
                if (r == 3) bText += "U";
                bText += "RPS";
                b.setText(bText);
                b.setTextSize(10.0f);
                b.setTextColor(Color.rgb(0, 0, 0));
                b.setOnClickListener(this);
                //b.setLayoutParams(cellLp);
                tr.addView(b, 75, 75);
            } // for
            layout.addView(tr);
        } // for

        super.setContentView(layout);
    } // ()

    public void onClick(View view) {
        mSoundManager.playSound(0);
    }
} // class
